Skip to content

Conversation

neithanmo
Copy link
Collaborator

Summary

This PR implements comprehensive support for Horizon (V2) TAP receipts by adding dual domain separator configuration and proper V2 verifier address handling across all services. This completes the foundation for full Horizon migration support in the indexer-rs ecosystem.

Changes Made

Configuration Updates

  • Added receipts_verifier_address_v2 field to BlockchainConfig for separate V2 contract addresses
  • Updated configuration examples (minimal and maximal) with documentation for the new V2 verifier field
  • Enhanced contrib scripts to extract and use both V1 (TAPVerifier) and V2 (GraphTallyCollector) addresses from horizon.json

Service Updates

  • Updated indexer-service to use correct V2 verifier address for domain separator creation
  • Updated tap-agent to use correct V2 verifier address for global domain separators
  • Added invariant validation: When horizon.enabled = true, receipts_verifier_address_v2 must be explicitly configured (fails fast with clear error)
  • Graceful fallback: When horizon.enabled = false, V2 operations fall back to V1 verifier address if V2 isn't specified

Infrastructure Updates

  • Updated integration test setup to support direct RAV testing workflows

Key Behavioral Changes

Horizon Configuration Invariants

  1. When horizon.enabled = true: Both services require explicit V2 verifier configuration and will fail fast with:

    receipts_verifier_address_v2 is required when Horizon is enabled
    
  2. When horizon.enabled = false: Both services gracefully fall back to V1 addresses for V2 domains

Domain Separator Logic

  • V1 domains: Always use receipts_verifier_address
  • V2 domains:
    • If Horizon enabled: Use receipts_verifier_address_v2 (required)
    • If Horizon disabled: Use receipts_verifier_address_v2 or fallback to receipts_verifier_address

Configuration Example

[blockchain]
chain_id = 1337
# V1 TAP verifier contract address
receipts_verifier_address = "0x1111111111111111111111111111111111111111"
# V2 (Horizon) verifier contract address - required when horizon.enabled = true
receipts_verifier_address_v2 = "0x2222222222222222222222222222222222222222"

[horizon]
# Enable Horizon migration support
enabled = true

Impact

This change resolves the "No sender found for signer" errors that occurred when V2 receipts were validated against incorrect verifier contracts. The dual domain approach ensures:

  • Correct cryptographic validation for both V1 and V2 receipt formats
  • Smooth migration path from legacy V1 to Horizon V2
  • Clear error reporting when configuration is incomplete
  • Backward compatibility for existing V1-only deployments

Testing

  • Configuration validation works correctly
  • Services fail fast when Horizon is enabled without V2 verifier
  • Services fall back gracefully when Horizon is disabled
  • Integration tests pass with dual domain support

Fix the TODO comment about mapping allocation types - now properly
detects Horizon contracts and maps allocations accordingly instead
of always using Legacy type
…able context

Enhance RAV request error messages to indicate which receipt table
(V1/Legacy vs V2/Horizon) was queried, helping with Horizon migration debugging
…acking

Add comprehensive debug and info logging throughout the allocation and escrow
account systems to improve troubleshooting of receipt processing, RAV generation, and
Horizon migration issues.
  - Reduce timestamp buffer from 1000s to 30s for faster RAV generation
  - Add trigger_value_divisor configuration for fine-tuned receipt batching
  - Set max_receipt_value_grt to 0.001 for controlled testing
  - Update tap-aggregator endpoint port configuration
@neithanmo neithanmo marked this pull request as draft August 22, 2025 14:40
  Add dual domain separator support for V1 (TAP) and V2 (GraphTally)
  protocols. This enables simultaneous processing of both legacy and
  Horizon receipt types with version-appropriate EIP712 domains
  Update service components to support both V1 and V2 domain separators
  simultaneously. Includes IndexerTapContext, ServiceRouter, and
  middleware updates for version-aware receipt processing.
  Critical fix for V2 receipt processing failures. Store receipts using
  version-appropriate domain separators to ensure correct signer recovery
  and escrow account lookup. Resolves "signer not found in V2 escrow accounts" errors.
  Implement version-aware receipt authorization that routes V1 and V2
  receipts to appropriate TAP managers. Includes new dual_tap_receipt_authorize
  function for simultaneous protocol support.
  Update sender middleware to use version-appropriate domain separators
  for signer recovery. V1 receipts use legacy domain, V2 receipts use
  Horizon domain for correct escrow account lookups.
  Add V2 domain separator support to sender account management, allocation
  handling, and receipt processing. Maintains single allocation type invariant
  while enabling version-appropriate domain usage.
  Update receipt validation checks and test infrastructure to support
  dual domain separators. Ensures proper EIP712 domain usage for
  both V1 and V2 receipt types in testing scenarios.
  Update integration tests, TAP agent tests, and service router tests
  to support V1/V2 dual domain architecture. Ensures comprehensive
  testing coverage for both protocol versions.
  - Add optional receipts_verifier_address_v2 to BlockchainConfig
  - Update configuration examples with V2 verifier documentation
  - Prepare infrastructure for dual domain separator support
  - Update indexer-service and tap-agent to use correct V2 verifier addresses
  - Add strict validation: V2 address required when horizon.enabled=true
  - Implement graceful fallback when Horizon is disabled
  - Remove static config.toml files from indexer-service and tap-agent
  - Update Dockerfiles to rely on start.sh for dynamic config generation
  - Clean up docker-compose.dev.yml by removing commented static config mounts
  - Ensure consistent contract file mounting across all Docker configurations
feat(sender_account): Propagate new subgraph_service_address to receipt layers

fix(horizon): use subgraph_service in query for V2 receipts
…ionId check

- Accept Horizon (V2) receipts that only provide collection_id by mapping the 32‑byte value to an Address
(last 20 bytes, right‑aligned).
- Preserve V1 behavior (use allocation_id() when present).
- Validate collection_id length and return a clear error when invalid.
- Add a small debug log comparing the resolved allocation_id to the expected one.
  - Add TestConfig struct with env-backed configuration
  - Add env_loader module for loading test environment variables

  This centralizes test configuration and makes it easier to run tests
  against different environments without hardcoding values.
  - Replace metrics-based checking with direct database state verification
  - Update test_tap_rav_v2 to use TestConfig and DatabaseChecker
  - Add detailed state tracking with pending receipt values
  - Add timeout-based RAV creation waiting with diagnostic output
…ging

  - Remove test_direct_service_rav_v2_simplified (299 lines)
  - Clean up debug logging in find_allocation function
  - Remove commented code and update function references in main.rs
  - Extend Docker health check timeouts from 30s to 120s
  - Add HTTP endpoint verification for indexer-service and tap-agent
  - Override allocation ID with known test value for consistency
  - Add 10s wait for indexer chain synchronization
  - Add optional pgAdmin startup for debugging
…return Result from start_agent

- Enforce hard startup error when horizon.enabled = true but Horizon isn’t active in the Network Subgraph (no silent fallback to V1).
- Error out if the Horizon readiness query fails (subgraph/network error) instead of proceeding.
- Convert start_agent to return anyhow::Result<(ActorRef<…>, JoinHandle<…>)> and propagate errors in main.
- Add contextual errors for watcher initialization and actor spawn (replace .expect(...) with .with_context(...)?).
…ployed

  Previously, both tap-agent and indexer-service would silently fall back
  to legacy (V1) mode when horizon.enabled=true but Horizon contracts
  weren't found in the network subgraph. This could lead to silent
  misconfigurations where operators expected V2 functionality but got V1.

  Changes:
  - tap-agent: Replace silent fallback with anyhow::bail! on missing contracts
  - indexer-service: Replace silent fallback with anyhow::bail! on missing contracts
  - Both services now fail at startup with clear error messages explaining:
    - How to disable Horizon (set horizon.enabled=false)
    - How to fix it (deploy Horizon contracts to network)
  - Replace .expect() calls with .with_context() for better error handling
…pport

- Add version-specific counters and gauges for unaggregated fees, RAV creation/failures, and response times
- Introduce `*_by_version` metrics with TAP version labels (v1/v2)
- Maintain backward compatibility by preserving legacy metrics for V1 only
- Add helper function `get_tap_version()` using type introspection to determine TAP version
- Support monitoring of dual V1/V2 protocol operations during migration
Replace horizon_enabled boolean and optional subgraph_service_address
fields with a TapMode enum that encapsulates TAP version modes.

- Add TapMode enum with Legacy and Horizon variants
- Legacy mode: V1 TAP receipts only
- Horizon mode: hybrid V1/V2 support with SubgraphService address
- Update all references from horizon_enabled to tap_mode.is_horizon()
- Replace direct subgraph_service_address access with pattern matching
- Add helper methods: is_legacy(), supports_v2(), v1_only()
- Update TapAgentContext to use Option<Address> for SubgraphService
- Add comprehensive documentation with usage examples

This improves type safety by ensuring SubgraphService address is only
accessible when actually configured for Horizon mode.
… contexts

The Horizon (V2) TAP receipt and RAV database queries require a subgraph_service_address
to filter records by the data_service field. Test contexts were not providing this address,
causing Horizon tests to fail with "SubgraphService address not available" errors.

Changes:
- Set subgraph_service_address in all Horizon TapAgentContext builders for tests
- Update Horizon test receipt/RAV creation to use consistent data_service addresses
- Ensure V2 receipts use TAP_SENDER.1 as data_service to match query expectations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant